package com.xk857.school.controller;


import com.xk857.entities.Card;
import com.xk857.school.req.AddCardREQ;
import com.xk857.school.service.IMyCardService;
import com.xk857.util.base.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author CV大魔王
 * @since 2021-05-02
 */
@Api(value = "校园卡找回管理接口", tags = "校园卡找回管理接口")
@RestController
@RequestMapping("/pri/card")
public class CardController {

    @Autowired
    private IMyCardService myCardService;

    @ApiOperation("发布捡卡或丢卡信息")
    @PostMapping
    public Result add(@RequestBody @Validated AddCardREQ card){
        return myCardService.add(card);
    }

    @ApiOperation("更新捡卡或丢卡信息")
    @PutMapping
    public Result update(@RequestBody Card card){
        return myCardService.update(card);
    }

    @ApiOperation("找回校园卡")
    @PutMapping("/complete/{cardId}")
    public Result updateComplete(@PathVariable String cardId){
        return myCardService.updateComplete(cardId);
    }

    @ApiOperation("捡到校园卡")
    @PutMapping("/pick/{cardId}")
    public Result updatePickUp(@PathVariable String cardId){
        return myCardService.updatePickUp(cardId);
    }

    @ApiOperation("删除捡卡或丢卡信息")
    @DeleteMapping("/{id}")
    public Result delete(@PathVariable String id){
        return myCardService.delete(id);
    }

}
